.NET Framework Class Library |
TaskCompletionSource<(Of <(TResult>)>)..::.TrySetException Method (Exception) |
TaskCompletionSource<(Of <(TResult>)>) Class See Also Send Feedback |
Attempts to transition the underlying
Task<(Of <(TResult>)>) into the
Faulted
state.
Namespace:
System.Threading.Tasks
Assembly:
System.Threading (in System.Threading.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Function TrySetException ( _ exception As Exception _ ) As Boolean |
C# |
---|
public bool TrySetException( Exception exception ) |
Parameters
- exception
- Type: System..::.Exception
The exception to bind to this Task<(Of <(TResult>)>).
Return Value
True if the operation was successful; otherwise, false.Remarks
This operation will return false if the
Task<(Of <(TResult>)>) is already in one
of the three final states:
RanToCompletion,
Faulted, or
Canceled.
Exceptions
Exception | Condition |
---|---|
System..::.ArgumentNullException | The exception argument is null. |
System..::.ObjectDisposedException | The Task was disposed. |